﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.IO;
using System.Runtime.InteropServices;
using System.Net.Sockets;
using System.Net;
using System.Collections;
using System.Threading;

namespace LjServer
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void Form1_Load(object sender, EventArgs e)
        {
            timerBroadcast.Enabled = true;
        }

        private void button1_Click(object sender, EventArgs e)
        {
            TcpServer.broadcast(richTextBox1.Text);
        }

        private void button2_Click(object sender, EventArgs e)
        {
            //TcpServer.StartListening();
            //Thread _th = new Thread(new ParameterizedThreadStart(startListening));
            //_th.IsBackground = true;
            //_th.Start();
            ThreadStart threadStart = new ThreadStart(startListening);
            Thread thread = new Thread(threadStart);
            thread.Start();
            timerBroadcast.Enabled = true;


        }
        public void startListening()
        {
            TcpServer.StartListening();
        }

        private void timerBroadcast_Tick(object sender, EventArgs e)
        {
            //TcpServer.broadcast("this is a broadcast message every 20s");
            TcpServer.broadcast(InvalidationReport.createReport());
        }

        private void button3_Click(object sender, EventArgs e)
        {
            richTextBox1.Text += "生成更新报告...\n";
            richTextBox1.Text += InvalidationReport.createReport();

         }
    }
}
